import requests



class IHRMDepartmentApi:
    # 封装部门添加的方法
    @classmethod
    def add_depart(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=header, json=body)
        return resp

    # 封装部门查询的方法
    @classmethod
    def query_depart(cls, depart_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + depart_id
        header = {"Authorization": token}
        resp = requests.get(url=url, headers=header)
        return resp

    # 封装部门修改的方法
    @classmethod
    def modify_depart(cls, depart_id, token, body):
        url = "  http://ihrm2-test.itheima.net/api/company/department/" + depart_id
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=header, json=body)
        return resp

    # 封装部门删除的方法
    @classmethod
    def del_depart(cls, depart_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + depart_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        return resp
